package com.orange.modules.dao;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.orange.dbhelp.DbHelper;
import com.orange.modules.entity.AuthItemMap;

@Repository
public class AuthItemMapRepository {

	@Autowired
	private AuthItemMapDao authItemMapDao;
	@Autowired
	private DbHelper dbhelper;
	
	/**
	 * 提交认证申请之后修改状态
	 * @throws SQLException 
	 */
	public void updateStateBySchool(String id,String state) throws SQLException{
		String sql = "update t_auth_item_map set s_iswrite = ? where s_school_id = ?";
		this.dbhelper.execute(sql, state,id);
	}
	
	/**
	 * 保存
	 */
	public void saveAuthItemMap(AuthItemMap a){
		this.authItemMapDao.save(a);
	}
	
	/**
	 * 查询
	 * @throws SQLException 
	 */
	public AuthItemMap queryOneByCondition(String schoolId,String itemid) throws SQLException{
		String sql = "select * from t_auth_item_map as t where t.s_school_id = ? and t.s_item_id = ?";
		return this.dbhelper.getBean(sql, AuthItemMap.class, schoolId,itemid);
	}
}
